import { TimeModel } from '../core';
import { TimeDataService } from '../core/TimeDataService';
import { Update } from '../../utils/ObjectUtil';
import { DateUtil } from '../../utils/DateUtil';

export interface Sample extends TimeModel {
	username: string;
	gender: boolean;
	nickname: string;
	phone: string;
	email: string;
	avatar: string;
	status: number;
}

class SampleService extends TimeDataService<
	SampleService,
	Sample,
	'createTime' | 'updateTime'
> {
	protected create(): SampleService {
		return this.initTokenInstance('user') as SampleService;
	}

	protected format(
		o: Sample
	): Update<Sample, 'createTime' | 'updateTime', string> {
		return DateUtil.formatObject(o, ['createTime', 'updateTime']);
	}

	protected time(
		o: Update<Sample, 'createTime' | 'updateTime', string>
	): Sample {
		return DateUtil.timeObject(o, ['createTime', 'updateTime']);
	}
}

export const sampleService = new SampleService();
